package org.smartboot.flow.core.invoker;

import org.smartboot.flow.core.trace.Node;
import org.smartboot.flow.core.trace.Tracer;

import java.util.concurrent.Callable;

/**
 * @author qinluo
 * @date 2022-12-07 21:57:39
 * @since 1.0.0
 */
public class AsyncRunner implements Callable<Integer> {

    private final Callable<Integer> task;
    private final Node root;

    public AsyncRunner(Callable<Integer> task) {
        this.task = task;
        this.root = Tracer.get();
    }

    @Override
    public Integer call() throws Exception {
        Tracer.setNode(root);
        return task.call();
    }
}
